package spring.advancedweb.excetion.handler;

import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import spring.advancedweb.excetion.DuplicateUserException;

/**
 * Created by kassadin@foxmail.com on 2017/4/30 0030.
 */

@ControllerAdvice
public class AppWideExceptionHandler {

    @ExceptionHandler(DuplicateUserException.class)
    public String duplicateUserHandler(Model model) {
        model.addAttribute("username", "user duplicate");
        return "user";
    }
}
